//
//  LGCiTangZuPuTreeViewController.m
//  ligenyun
//
//  Created by Mac on 2018/3/26.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGCiTangZuPuTreeViewController.h"
#import "LGCiTangZuPuAddPeopleViewController.h"
#import "LGCiTangRolationPresentViewController.h"
@interface LGCiTangZuPuTreeViewController ()
@property(nonatomic, strong)LGTypeChosedControl                     *typeControle;
@end

@implementation LGCiTangZuPuTreeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configSubView];
    
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        [self presentViewController:[LGCiTangRolationPresentViewController new] animated:NO completion:nil];
    });
    // Do any additional setup after loading the view.
}

#pragma mark --subView
- (void)configSubView{
    
    self.tableView.frame = CGRectMake(0, 0, UIScreenWidth, [TMUtils tabBarTop] + 49 - ([TMUtils navgationBarBootom] + 44));
    self.tableView.contentInset = UIEdgeInsetsZero;
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 40)];
    __weak typeof(self) weakSelf =  self;
    LGTypeChosedControl * typeControl = [[LGTypeChosedControl alloc] initWithFrame:CGRectMake(-2, 30, 65, 30) title:@"十代"];
    typeControl.titleLable.textAlignment = NSTextAlignmentRight;
    [typeControl setClction:^(LGTypeChosedControl *control) {
        [weakSelf onSelctedAddPeopleButton];
    }];
    typeControl.layer.cornerRadius = 4;
    typeControl.clipsToBounds = YES;
    [header addSubview:typeControl];
    
    
    UIImageView * imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 90, 300, 140)];
    imageview.centerX = UIScreenWidth / 2;
    imageview.image = [UIImage imageNamed:@"添加族人bg"];
    imageview.userInteractionEnabled = YES;
    [header addSubview:imageview];
    
    STButton * addButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 200, 44)
                                                     title:@"点击马上添加族人"
                                                titleColor:FirstTextColor
                                                 titleFont:14
                                              cornerRadius:0
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:[UIImage imageNamed:@"icon_添加"]];
    addButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [imageview addSubview:addButton];
    [addButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelctedGenerationButton];
    }];
    addButton.centerX = imageview.width / 2;
    addButton.centerY = imageview.height / 2;
    addButton.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
    
    header.height = imageview.bottom;
    self.tableView.tableHeaderView = header;
    
    
    
}
#pragma mark --Action Method
- (void)onSelctedAddPeopleButton{
    
}
- (void)onSelctedGenerationButton{
    [self presentViewController:[LGCiTangZuPuAddPeopleViewController new] animated:NO completion:nil];
}
@end
